import 'dart:convert';
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/style.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:shop/config/config.dart';
import 'package:shop/http/HttpUtil.dart';
import 'package:shop/route/my_route.dart';
import 'package:shop/shop/merchant/GoodsInfoEdit.dart';
import 'package:shop/shop/merchant/GoodsListInfo.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:shop/shop/merchant/ServiceEdit.dart';
import 'SoldOutPage.dart';

class GoodsList extends StatefulWidget {
  GoodsList({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _GoodsList createState() => _GoodsList();
}

class _GoodsList extends State<GoodsList> with TickerProviderStateMixin {

  SharedPreferences prefs;
  String merchantID=""; //商户ID
  List typeList = [];   //类型集合
  List goodsList = [];  //商品集合
  List shouqingGoods=[];//售罄商品集合
  List xiajiaGoods=[];  //下架商品集合
  int xiabiao=0;        //选中下标
  int typeXiabiao=0;    //选中商品类型下标
  int zaishou=0;        //在售商品数量
  int shouqing=0;       //售罄商品数量
  int xiajia=0;         //下架商品数量
  String mType="0";     //商户类型（0：外卖型商户  1：服务型商户）

  // 顶部tabbar
  TabController mController;//tab控制器

  // 加载商户的商品分类
  _getTypeList() async{
    prefs = await SharedPreferences.getInstance();
    merchantID = prefs.getString("merchantID");
    mType = prefs.getString("mType");
    var res  =await HttpUtil().get("/waimai/mGoodsType/getMerchantGoodsNum?mId="+merchantID );
    if(res['code']==200){
      zaishou = res['data']['zaishou'];
      shouqing = res['data']['shouqing'];
      xiajia = res['data']['xiajia'];
    }
    //类型和商品
    var x  =await HttpUtil().get("/waimai/mGoodsType/getMerchantAllGoodsType?mId="+merchantID );
    if(x['code']==200){
      typeList = x['data'];
      if(typeXiabiao != 0){
        goodsList = typeList[typeXiabiao]['mgoodsList'];
      }else{
        goodsList = typeList[0]['mgoodsList'];
      }
    }
    //售罄商品
    var y  =await HttpUtil().get("/waimai/mGoods/getSoldOutPage?mId="+merchantID+"&type=0");
    if(y['code']==200){
      shouqingGoods = y['data'];
    }
    //下架商品
    var z  =await HttpUtil().get("/waimai/mGoods/getSoldOutPage?mId="+merchantID+"&type=1");
    if(z['code']==200){
      xiajiaGoods = z['data'];
    }
    setState(() {

    });
  }

  //初始化数据
  @override
  void initState() {
    super.initState();
    _getTypeList();
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context , width: 464 , height: 820) ;
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0.0,
        title: Text(mType=="0" ? "商品管理" : "服务管理",style: TextStyle(color: Colors.black),),
        centerTitle: true,
      ),
      body: Column(
        children: [
          Container(
            padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
            decoration: BoxDecoration(
                color: Colors.white
            ),
            child: Column(
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    GestureDetector(child: Container(
                      padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
                      decoration: BoxDecoration(
                          border:xiabiao==0 ? Border(bottom: BorderSide(width: 2,color: Colors.orange)) : Border(bottom: BorderSide(style: BorderStyle.none))
                      ),
                      child: Row(
                        children: [
                          Text("在售",style: TextStyle(fontSize: 20,fontWeight: FontWeight.w500),),
                          SizedBox(width: 3,),
                          Text(zaishou.toString(),style: TextStyle(fontSize:15,color: Colors.black54,fontWeight: FontWeight.w400),),
                        ],
                      ),
                    ),onTap: (){
                      xiabiao = 0;
                      setState(() {

                      });
                    },),
                    GestureDetector(child: Container(
                      padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
                      decoration: BoxDecoration(
                          border:xiabiao==1 ? Border(bottom: BorderSide(width: 2,color: Colors.orange)) : Border(bottom: BorderSide(style: BorderStyle.none))
                      ),
                      child: Row(
                        children: [
                          Text("已售罄",style: TextStyle(fontSize: 20,fontWeight: FontWeight.w500),),
                          SizedBox(width: 3,),
                          Text(shouqing.toString(),style: TextStyle(fontSize:15,color: Colors.black54,fontWeight: FontWeight.w400),),
                        ],
                      ),
                    ),onTap: (){
                      xiabiao = 1;
                      setState(() {

                      });
                    },),
                    GestureDetector(child: Container(
                      padding: EdgeInsets.fromLTRB(15, 10, 15, 10),
                      decoration: BoxDecoration(
                          border:xiabiao==2 ? Border(bottom: BorderSide(width: 2,color: Colors.orange)) : Border(bottom: BorderSide(style: BorderStyle.none))
                      ),
                      child: Row(
                        children: [
                          Text("下架",style: TextStyle(fontSize: 20,fontWeight: FontWeight.w500),),
                          SizedBox(width: 3,),
                          Text(xiajia.toString(),style: TextStyle(fontSize:15,color: Colors.black54,fontWeight: FontWeight.w400),),
                        ],
                      ),
                    ),onTap: (){
                      xiabiao = 2;
                      setState(() {

                      });
                    },),
                  ],
                ),
              ],
            ),
          ),
          xiabiao==0 ? Expanded(
            child: Container(
              decoration: BoxDecoration(
                border: Border(top: BorderSide(width: 1,color: Colors.black12))
              ),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Container(
                    height: ScreenUtil().setHeight(820),
                    // const color = Color(OxFFEFFOFO);
                    color: fromHex('#eff0f0'),
                    child: SingleChildScrollView(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          _getGoodsType(),
                        ],
                      ),
                    ),
                  ),
                  Expanded(
                    child: Container(
                      // padding: EdgeInsets.fromLTRB(0, 10, 0, 0),
                      child: ListView(
                        children: [
                          _getGoods()
                        ],
                      ),
                    )
                  )
                ],
              ),
            ),
          ) : Expanded(
            child: Container(
              decoration: BoxDecoration(
                  border: Border(top: BorderSide(width: 1,color: Colors.black12))
              ),
              padding: EdgeInsets.fromLTRB(0, 15, 0, 0),
              child: ListView(
                children: [
                  xiabiao==1 ? _getShouQingXiajiaGoods(shouqingGoods) : _getShouQingXiajiaGoods(xiajiaGoods)
                ],
              ),
              // child: Column(
              //   children: [
              //     xiabiao==1 ? _getShouQingXiajiaGoods(shouqingGoods) : _getShouQingXiajiaGoods(xiajiaGoods),
              //   ],
              // ),
            ),
          )
        ],
      ),
      floatingActionButton: FloatingActionButton(
        tooltip: "新增新品",
        child: Icon(Icons.add),
        onPressed: (){
          if(mType=="0"){
            MyRoute.push(GoodsInfoEdit(guiges: [],type: 1,));//新增外卖商品
          }else{
            MyRoute.push(ServiceEdit(guiges: [],type: 1,));//新增服务商品
          }
        },
      ),
    );
  }

  Color fromHex(String hexString) {
    final buffer = StringBuffer();
    if (hexString.length == 6 || hexString.length == 7) buffer.write('ff');
    buffer.write(hexString.replaceFirst('#', ''));
    return Color(int.parse(buffer.toString(), radix: 16));
  }

  //售罄和下架商品
  Widget _getShouQingXiajiaGoods(goodsLists){
    List<Widget> x = [];
    if(goodsLists.length<1){
      x.add(Container(
          padding: EdgeInsets.fromLTRB(0,10,0,0),
          child: Text("未找到商品")
      ));
    }else{
      for(int i=0;i<goodsLists.length;i++){
        x.add(
          GestureDetector(
            child:  Container(
              color: Colors.white,
              padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10),
              margin: EdgeInsets.only(bottom: 10),
              child:
              Row(
                children: [
                  Image.network(Config.getInstance().getHost()+goodsLists[i]['gimages'],height: ScreenUtil().setHeight(110),width: ScreenUtil().setHeight(110),fit: BoxFit.fitHeight,),
                  // Image.network(Config.getInstance().getHost()+goodsList[i]['gimages'],width: 60,height: 60,),
                  SizedBox(width: ScreenUtil().setWidth(16),),
                  Expanded(child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Container(
                        width: ScreenUtil().setWidth(205),
                        // height: ScreenUtil().setHeight(30),
                        child: Row(
                          children: [
                            Expanded(child: Text(goodsLists[i]['gname'],maxLines:1,overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: ScreenUtil().setSp(20)),)),
                          ],
                        ),
                      ),
                      SizedBox(height: ScreenUtil().setWidth(5),),
                      Row(
                        children: [
                          Text("月售:"+goodsLists[i]['gsellnum'].toString(),style: TextStyle(fontSize: ScreenUtil().setHeight(14)),),
                          Container(
                            padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
                            child: Text("好评:"+goodsLists[i]['haopingdu'].toString()+"%",style: TextStyle(fontSize: ScreenUtil().setHeight(14)),),
                          ),
                        ],
                      ),
                      SizedBox(height: ScreenUtil().setWidth(5),),
                      mType=="0" ?
                      Row(
                        children: [
                          Text("￥",style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600),),
                          Text(goodsLists[i]['gprice'].toString(),style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600,fontSize: 19),)
                        ],
                      ) : Row(),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.end,
                        children: [
                          xiabiao==2 ? Container(
                            padding: EdgeInsets.symmetric(vertical: 5,horizontal: 10),
                            decoration: BoxDecoration(
                              border: Border.all(color: Colors.black , width: 0) ,
                              borderRadius:BorderRadius.circular(4),
                            ),
                            child: GestureDetector(child: Text("上架商品"),onTap: () async {
                              var x = await HttpUtil().get("/waimai/mGoods/goodsUp?gid="+goodsLists[i]['id']);
                              if(x['code']==200){
                                Fluttertoast.showToast(msg: "上架成功");
                                _getTypeList();
                              }
                            },),
                          ) : Text(""),
                          SizedBox(width: ScreenUtil().setWidth(20),),
                          GestureDetector(
                            child: Container(
                              padding: EdgeInsets.symmetric(vertical: 5,horizontal: 20),
                              // color: Colors.orangeAccent,
                              decoration: BoxDecoration(
                                color: Colors.orangeAccent,
                                // border: Border.all(color: Colors.black , width: 0) ,
                                borderRadius:BorderRadius.circular(4),
                              ),
                              child: Text("编辑",style: TextStyle(color: Colors.white),),
                            ),
                            onTap: (){
                              // print("修改商品："+goodsList[i]['gname']);
                              var tu6;var tu7;var tu8;
                              if(goodsLists[i]['image6'] != null){
                                tu6 = goodsLists[i]['image6'].toString().substring(2,goodsLists[i]['image6'].toString().length-1);
                              }
                              if(goodsLists[i]['image7'] != null){
                                tu7 = goodsLists[i]['image7'].toString().substring(2,goodsLists[i]['image7'].toString().length-1);
                              }
                              if(goodsLists[i]['image8'] != null){
                                tu8 = goodsLists[i]['image8'].toString().substring(2,goodsLists[i]['image8'].toString().length-1);
                              }
                              List guigess = json.decode(goodsLists[i]['guige']);
                              if(mType=="0"){
                                MyRoute.push(GoodsInfoEdit(type: 2,guiges: guigess,tu1: goodsLists[i]['gimages'],tu2: goodsLists[i]['image2'],tu3: goodsLists[i]['image3'],tu4: goodsLists[i]['image4'],tu5: goodsLists[i]['image5'],tu6: tu6,tu7: tu7,tu8: tu8,gName: goodsLists[i]['gname'],gPrice: goodsLists[i]['gprice'].toString(),goodsTypeName: goodsLists[i]['mgoodsType']['name'],danwei: goodsLists[i]['gdanwei'],kucun: goodsLists[i]['kucun'].toString(),miaoshu: goodsLists[i]['jianjie'],id: goodsLists[i]['id'],fuwuPicture: goodsLists[i]['fuwuPicture'],detailPicture: goodsLists[i]['detailPicture'],));
                              }else{
                                MyRoute.push(ServiceEdit(guiges: [],type: 2,gName: goodsLists[i]['gname'],goodsTypeName: goodsLists[i]['mgoodsType']['name'],danwei: goodsLists[i]['gdanwei'],miaoshu: goodsLists[i]['jianjie'],id: goodsLists[i]['id'],fuwuPicture: goodsLists[i]['fuwuPicture'],detailPicture: goodsLists[i]['detailPicture'],));
                              }
                            },
                          )
                        ],
                      ),
                    ],
                  ),)
                ],
              ),
            ),
            onTap: (){

            },
            behavior: HitTestBehavior.opaque,
          ),
          // GestureDetector(
          //   child:  Container(
          //     padding: EdgeInsets.symmetric(horizontal: 10),
          //     child: Column(
          //       children: [
          //         Row(
          //           mainAxisAlignment: MainAxisAlignment.spaceBetween,
          //           children: [
          //             Container(
          //               child: Row(
          //                 children: [
          //                   // Image.network(Config.getInstance().getHost()+goodsLists[i]['gimages'],width: 60,height: 60,),
          //                   Container(
          //                     width: ScreenUtil().setWidth(95),
          //                     height: ScreenUtil().setHeight(90),
          //                     decoration: BoxDecoration(
          //                       // border: Border.all(color: Colors.black , width: 0),
          //                       borderRadius:BorderRadius.circular(4),
          //                     ),
          //                     child: Image.network(Config.getInstance().getHost()+goodsLists[i]['gimages']),
          //                   ),
          //                   SizedBox(width: 15,),
          //                   Column(
          //                     crossAxisAlignment: CrossAxisAlignment.start,
          //                     children: [
          //                       Container(
          //                         width: ScreenUtil().setWidth(320),
          //                         child: Row(
          //                           children: [
          //                             Expanded(child: Text(goodsLists[i]['gname'],style: TextStyle(fontSize: 16),)),
          //                           ],
          //                         ),
          //                       ),
          //                       Row(
          //                         children: [
          //                           Text("月售:"+goodsLists[i]['gsellnum'].toString(),style: TextStyle(fontSize: 13),),
          //                           Container(
          //                             padding: EdgeInsets.fromLTRB(20, 0, 0, 0),
          //                             child: Text("好评:"+goodsLists[i]['haopingdu'].toString()+"%",style: TextStyle(fontSize: 13),),
          //                           ),
          //                         ],
          //                       ),
          //                       mType=="0" ?
          //                       Row(
          //                         children: [
          //                           Text("￥",style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600),),
          //                           Text(goodsLists[i]['gprice'].toString(),style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600,fontSize: 19),)
          //                         ],
          //                       ) : Row(),
          //                       Row(
          //                         mainAxisAlignment: MainAxisAlignment.end,
          //                         children: [
          //                           xiabiao==2 ? Container(
          //                             padding: EdgeInsets.symmetric(vertical: 5,horizontal: 10),
          //                             decoration: BoxDecoration(
          //                               border: Border.all(color: Colors.black , width: 0) ,
          //                               borderRadius:BorderRadius.circular(4),
          //                             ),
          //                             child: GestureDetector(child: Text("上架商品"),onTap: () async {
          //                               var x = await HttpUtil().get("/waimai/mGoods/goodsUp?gid="+goodsLists[i]['id']);
          //                               if(x['code']==200){
          //                                 Fluttertoast.showToast(msg: "上架成功");
          //                                 _getTypeList();
          //                               }
          //                             },),
          //                           ) : Text(""),
          //                           SizedBox(width: ScreenUtil().setWidth(20),),
          //                           GestureDetector(
          //                             child: Container(
          //                               padding: EdgeInsets.symmetric(vertical: 5,horizontal: 20),
          //                               // color: Colors.orangeAccent,
          //                               decoration: BoxDecoration(
          //                                 color: Colors.orangeAccent,
          //                                 // border: Border.all(color: Colors.black , width: 0) ,
          //                                 borderRadius:BorderRadius.circular(4),
          //                               ),
          //                               child: Text("编辑",style: TextStyle(color: Colors.white),),
          //                             ),
          //                             onTap: (){
          //                               // print("修改商品："+goodsList[i]['gname']);
          //                               var tu6;var tu7;var tu8;
          //                               if(goodsLists[i]['image6'] != null){
          //                                 tu6 = goodsLists[i]['image6'].toString().substring(2,goodsLists[i]['image6'].toString().length-1);
          //                               }
          //                               if(goodsLists[i]['image7'] != null){
          //                                 tu7 = goodsLists[i]['image7'].toString().substring(2,goodsLists[i]['image7'].toString().length-1);
          //                               }
          //                               if(goodsLists[i]['image8'] != null){
          //                                 tu8 = goodsLists[i]['image8'].toString().substring(2,goodsLists[i]['image8'].toString().length-1);
          //                               }
          //                               List guigess = json.decode(goodsLists[i]['guige']);
          //                               if(mType=="0"){
          //                                 MyRoute.push(GoodsInfoEdit(type: 2,guiges: guigess,tu1: goodsLists[i]['gimages'],tu2: goodsLists[i]['image2'],tu3: goodsLists[i]['image3'],tu4: goodsLists[i]['image4'],tu5: goodsLists[i]['image5'],tu6: tu6,tu7: tu7,tu8: tu8,gName: goodsLists[i]['gname'],gPrice: goodsLists[i]['gprice'].toString(),goodsTypeName: goodsLists[i]['mgoodsType']['name'],danwei: goodsLists[i]['gdanwei'],kucun: goodsLists[i]['kucun'].toString(),miaoshu: goodsLists[i]['jianjie'],id: goodsLists[i]['id'],fuwuPicture: goodsLists[i]['fuwuPicture'],detailPicture: goodsLists[i]['detailPicture'],));
          //                               }else{
          //                                 MyRoute.push(ServiceEdit(guiges: [],type: 2,gName: goodsLists[i]['gname'],goodsTypeName: goodsLists[i]['mgoodsType']['name'],danwei: goodsLists[i]['gdanwei'],miaoshu: goodsLists[i]['jianjie'],id: goodsLists[i]['id'],fuwuPicture: goodsLists[i]['fuwuPicture'],detailPicture: goodsLists[i]['detailPicture'],));
          //                               }
          //                             },
          //                           )
          //                         ],
          //                       ),
          //                     ],
          //                   )
          //                 ],
          //               ),
          //             ),
          //           ],
          //         ),
          //         SizedBox(height: 5,),
          //         Divider()
          //       ],
          //     ),
          //   ),
          //   onTap: (){
          //
          //   },
          //   behavior: HitTestBehavior.opaque,
          // ),
        );
      }
    }
    return Column(
      children: x,
    );
  }

  //在售商品
  Widget _getGoods(){
    List<Widget> x = [];
    if(goodsList.length<1){
      x.add(Container(
          padding: EdgeInsets.fromLTRB(0,10,0,0),
          child: Text("未找到商品")
      ));
    }else{
      for(int i=0;i<goodsList.length;i++){
        x.add(
          GestureDetector(
            child:  Container(
              color: Colors.white,
              padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10),
              margin: EdgeInsets.only(bottom: 10),
              child:
                Row(
                  children: [
                    Image.network(Config.getInstance().getHost()+goodsList[i]['gimages'],height: ScreenUtil().setHeight(110),width: ScreenUtil().setHeight(110),fit: BoxFit.fitHeight,),
                    // Image.network(Config.getInstance().getHost()+goodsList[i]['gimages'],width: 60,height: 60,),
                    SizedBox(width: ScreenUtil().setWidth(16),),
                    Expanded(child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          width: ScreenUtil().setWidth(205),
                          // height: ScreenUtil().setHeight(30),
                          child: Row(
                            children: [
                              Expanded(child: Text(goodsList[i]['gname'],maxLines:1,overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: ScreenUtil().setSp(20)),)),
                            ],
                          ),
                        ),
                        SizedBox(height: ScreenUtil().setWidth(5),),
                        Row(
                          children: [
                            Text("月售:"+goodsList[i]['gsellnum'].toString(),style: TextStyle(fontSize: ScreenUtil().setHeight(14)),),
                            Container(
                              padding: EdgeInsets.fromLTRB(10, 0, 0, 0),
                              child: Text("好评:"+goodsList[i]['haopingdu'].toString()+"%",style: TextStyle(fontSize: ScreenUtil().setHeight(14)),),
                            ),
                          ],
                        ),
                        SizedBox(height: ScreenUtil().setWidth(5),),
                        mType=="0" ?
                        Row(
                          children: [
                            Text("￥",style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600),),
                            Text(goodsList[i]['gprice'].toString(),style: TextStyle(color: Colors.red,fontWeight: FontWeight.w600,fontSize: 19),)
                          ],
                        ) : Row(),
                        SizedBox(height: ScreenUtil().setWidth(5),),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.end,
                          children: [
                            Container(
                              padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(5),horizontal: ScreenUtil().setHeight(9)),
                              decoration: BoxDecoration(
                                border: Border.all(color: Colors.black , width: 1),
                                borderRadius:BorderRadius.circular(4),
                              ),
                              child: GestureDetector(child: Text("下架商品"),onTap: () async {
                                var x = await HttpUtil().get("/waimai/mGoods/goodsDown?gid="+goodsList[i]['id']);
                                if(x['code']==200){
                                  Fluttertoast.showToast(msg: "下架成功");
                                  _getTypeList();
                                }
                              },),
                            ),
                            SizedBox(width: ScreenUtil().setHeight(10),),
                            GestureDetector(
                              child: Container(
                                padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(7),horizontal: ScreenUtil().setHeight(20)),
                                // color: Colors.orangeAccent,
                                decoration: BoxDecoration(
                                  color: Colors.orangeAccent,
                                  borderRadius:BorderRadius.circular(4),
                                  // border: Border.all(color: Colors.black , width: 0) ,
                                ),
                                child: Text("编辑",style: TextStyle(color: Colors.white),),
                              ),
                              onTap: (){
                                // print("修改商品："+goodsList[i]['gname']);
                                var tu6;var tu7;var tu8;
                                if(goodsList[i]['image6'] != null){
                                  tu6 = goodsList[i]['image6'].toString().substring(2,goodsList[i]['image6'].toString().length-1);
                                }
                                if(goodsList[i]['image7'] != null){
                                  tu7 = goodsList[i]['image7'].toString().substring(2,goodsList[i]['image7'].toString().length-1);
                                }
                                if(goodsList[i]['image8'] != null){
                                  tu8 = goodsList[i]['image8'].toString().substring(2,goodsList[i]['image8'].toString().length-1);
                                }
                                List guigess = json.decode(goodsList[i]['guige']);
                                // print('服务图片：'+goodsList[i]['fuwuPicture']);
                                // print('详情图片：'+goodsList[i]['detailPicture']);
                                if(mType=="0"){
                                  MyRoute.push(GoodsInfoEdit(type: 2,guiges: guigess,tu1: goodsList[i]['gimages'],tu2: goodsList[i]['image2'],tu3: goodsList[i]['image3'],tu4: goodsList[i]['image4'],tu5: goodsList[i]['image5'],tu6: tu6,tu7: tu7,tu8: tu8,gName: goodsList[i]['gname'],gPrice: goodsList[i]['gprice'].toString(),goodsTypeName: goodsList[i]['mgoodsType']['name'],danwei: goodsList[i]['gdanwei'],kucun: goodsList[i]['kucun'].toString(),miaoshu: goodsList[i]['jianjie'],id: goodsList[i]['id'],fuwuPicture: goodsList[i]['fuwuPicture'],detailPicture: goodsList[i]['detailPicture'],));
                                }else{
                                  MyRoute.push(ServiceEdit(guiges: [],type: 2,gName: goodsList[i]['gname'],goodsTypeName: goodsList[i]['mgoodsType']['name'],danwei: goodsList[i]['gdanwei'],miaoshu: goodsList[i]['jianjie'],id: goodsList[i]['id'],fuwuPicture: goodsList[i]['fuwuPicture'],detailPicture: goodsList[i]['detailPicture'],));
                                }
                              },
                            )
                          ],
                        ),
                      ],
                    ),
                  )
                ],
              ),
            ),
            onTap: (){

            },
            behavior: HitTestBehavior.opaque,
          ),
        );
      }
    }
    return Column(
      children: x,
    );
  }

  //商品类型
  Widget _getGoodsType(){
    List<Widget> x = [];
    for(int i=0;i<typeList.length;i++){
      x.add(
        GestureDetector(child: Container(
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: typeXiabiao==i ? Colors.white : null
          ),
          child: GestureDetector(
            child: Row(
              children: [
                Expanded(child: Center(child: Text(typeList[i]['name'],style: TextStyle(fontSize: 17,color: typeXiabiao==i ? Colors.black : Colors.black38,fontWeight: FontWeight.w500))))
              ],
            ),behavior: HitTestBehavior.opaque,
          ),width: 100,padding: EdgeInsets.fromLTRB(0,15,0,15),
          // ),width: 90,padding: EdgeInsets.symmetric(vertical: 10),
        ),onTap: (){
          typeXiabiao=i;
          goodsList=typeList[i]['mgoodsList'];
          setState(() {

          });
        },)
      );
    }
    return Container(
      child: Column(children: x),
    );
  }
}